public class Demo2 {
    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(()->{
            for (int i = 0; i < 5; i++) {
                try {
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        });
        // getState() 获得当前线程的状态
        System.out.println(thread.getState());
        thread.start();
        for (int i = 0; i < 3; i++) {
            System.out.println(thread.getState());
            Thread.sleep(200);
        }
        thread.join();
        System.out.println(thread.getState());
    }
}
